<?php
require_once 'google-analytics-generator.class.php';
require_once 'abtest.class.php';	

$trackerId = $_GET['trackerId'];

$googleAnalyticGenerator = new GoogleAnalyticsGenerator($trackerId);
$googleAnalyticGenerator->setDebugModeActive(true);

$defaultTestCase = new TestCase('default', 0, '<p>default</p>');
$a = new TestCase('a', 39, '<p>a</p>');
$b = new TestCase('b', 10, '<p>b</p>');
$c = new TestCase('c', 50, '<p>c</p>');

$abtest = new ABTest('ab1', $defaultTestCase);
//$abtest->addTestCase($a);
//$abtest->addTestCase($b);
//$abtest->addTestCase($c);

?>
<html>
<head>
<title>ABTest tester</title>
</head>
<body>

<h1>ABTest:</h1>
<div style="border:1px solid #000000; width:100px; height:100px;">
<?php 

$arr = array('default' => 0);

for ($i = 0; $i < 1000; $i++) {
	$winner = $abtest->rollTheDice();
	
	if (!$winner) {
		echo "error!";
		break;	
	}

	$arr[$winner->getName()] ++;
}
echo "default: {$arr['default']} <br />";

?>
</div>

<?php 
echo $googleAnalyticGenerator->generateSetupScriptTag();
echo $googleAnalyticGenerator->generateVariablesScriptTag();
?>
</body>

</html>